import Vue from 'vue'
import Router from 'vue-router'
//import Home from '@/pages/Home/Home'
// import City from '@/pages/city/City'
import Detail from '@/pages/Detail/Detail'
import Test from '@/pages/test/index1'

// const Home = () =>
//   import ('@/pages/Home/Home' /* webpackChunkName: "group-home" */ );

  // const Home = () => import(/* webpackChunkName: "group-foo" */ '@/pages/Home/Home')
  // const City = () => import(/* webpackChunkName: "group-City" */ '@/pages/city/City')
 const Home = r => require.ensure([], () => r(require('@/pages/Home/Home')), 'group-Home') 
  const City = r => require.ensure([], () => r(require('@/pages/city/City')), 'group-City') 


Vue.use(Router)

export default new Router({
  routes: [{
      path: '/',
      name: 'Home',
      component: Home
    },
    {
      path: '/city',
      name: 'City',
      component: City
    },
    {
      path: '/detail/:id', //动态路由
      name: 'Detail',
      component: Detail
    },
    {
      path: '/test', //动态路由
      name: 'Test',
      component: Test
    }
  ],
  scrollBehavior(to, from, savedPosition) { //每次路由切换时，都让新进入显示的页面始终都回到最顶部
    return {
      x: 0,
      y: 0
    }
  }
})
